package com.ysd.servlet;

import java.io.IOException;

import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.CompanyDaoImpl;
import com.ysd.dao.impl.NewsCategoryDaoImpl;
import com.ysd.dao.impl.NewsDaoImpl;
import com.ysd.entity.Company;
import com.ysd.entity.News;
import com.ysd.entity.NewsCategory;

public class NewsDetallServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		CompanyDaoImpl cDao = new CompanyDaoImpl();
		Company c = cDao.getCompany();
		
		request.setAttribute("c", c);

		NewsCategoryDaoImpl nCDao = new NewsCategoryDaoImpl();
		List<NewsCategory> n = nCDao.getNewsCategory();
		request.setAttribute("n", n);
		
		int nId = Integer.parseInt(request.getParameter("newsId"));
		NewsDaoImpl nDo = new NewsDaoImpl();
		List<News> nw = nDo.getNews1(nId);
		request.setAttribute("nw", nw);
		
		
		int Id = Integer.parseInt(request.getParameter("newsId"));
		NewsDaoImpl nDao = new NewsDaoImpl();
		List<News> d = nDao.getNewsId(Id);
		request.setAttribute("d", d);
		
		int bId = Integer.parseInt(request.getParameter("newsId"));
		NewsDaoImpl nbao = new NewsDaoImpl();
		List<News> b = nbao.getNewsId(bId);
		request.setAttribute("b", b);
		
		
		
		request.getRequestDispatcher("article_list_content.jsp").forward(request, response);

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
